package com.hxzy.login_2;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;


/**
 * Created by Administrator on 2016/9/14.
 */
public class MyTitleBar extends RelativeLayout{
    private  String leftBtnText,titleText,rightText;

    public MyTitleBar(Context context){
        this(context,null);
    }
    public MyTitleBar(Context context, AttributeSet attrs){
        this(context,attrs,0);
    }
    public MyTitleBar(Context context, AttributeSet attrs, int defStyleAttr){
        super(context,attrs,defStyleAttr);
        View.inflate(context, R.layout.widget_my_title_bar,this);

        TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.MyTitleBar);
        leftBtnText = ta.getString(R.styleable.MyTitleBar_leftBtnText);
        titleText = ta.getString(R.styleable.MyTitleBar_titleText);
        rightText = ta.getString(R.styleable.MyTitleBar_rightBtnText);
        ta.recycle();

        TextView leftBtn = (TextView) findViewById(R.id.left_btn);
        TextView title = (TextView) findViewById(R.id.title_tv);
        TextView rightBtn = (TextView) findViewById(R.id.right_btn);

        if (leftBtnText != null) leftBtn.setText(leftBtnText);
        if (titleText != null) title.setText(titleText);
        if (rightText != null) rightBtn.setText(rightText);
    }
    private void init(){

    }
}
